package com.sl.core.engine.datasource.interceptor;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import org.apache.hop.core.logging.ILogChannel;
import org.beetl.sql.core.InterceptorContext;
import org.beetl.sql.ext.DebugInterceptor;

public class LogDebugInterceptor extends DebugInterceptor {

    private ILogChannel logChannel;
    public LogDebugInterceptor(ILogChannel logChannel) {
        this.logChannel = logChannel;
    }

    @Override
    public void before(InterceptorContext ctx) {
        super.before(ctx);
        Object o = ctx.get("logs");
        if(ObjectUtil.isNotNull(o)&&ObjectUtil.isNotNull(logChannel)){
            logChannel.logBasic(StrUtil.toString(o));
        }
    }
}
